<?php
extract($plan);
?>
<form name="form_cancela" method="post" action="<?php echo base_url()?>index.php/social/cancela_plan" enctype="multipart/form-data" accept-charset="utf-8">
<input type="hidden" name="id_plan" value="<?php echo $id_plan ?>">
<input type="hidden" name="numero" value="<?php echo $numero ?>">
	<div id="wizard" class="swMain">
        <ul>
            <li>
                <a href="#step-1">
                    <span class="stepNumber">1<small>er</small></span>
                    <span class="stepDesc">
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Paso<br/>
                        <small>&nbsp;Observaciones</small>
                    </span>
                </a>
            </li>
        </ul>
        <div id="step-1">
        	<h2 class="StepTitle">Observaciones o Razones por las que se Cancela el Plan</h2>
            <p>
            	<label class="label_textarea">Observaciones o Razones: </label>
                <textarea name="observacion" id="observacion" style="resize:none; width:200px"></textarea>
            </p>
            <p>
            	<label>Constancia o Documento (Opcional): </label>
                <input type="file" name="userfile" id="userfile" onchange="validate_fileupload(this.value)">
            </p>
        </div>
    </div>
</form>
<script>
$(document).ready(function(){
	
	$('#wizard').smartWizard();
	$('#observacion').validacion({
		req:true,
		lonMin:10
	});
});


function validate_fileupload(fileName)
{
     var allowed_extensions = new Array("DOC","doc","DOCX","docx","PDF","pdf","XPS","xps","JPG","jpg","PNG","png","GIF","gif");
    var file_extension = fileName.split('.').pop(); // split function will split the filename by dot(.), and pop function will pop the last element from the array which will give you the extension as well. If there will be no extension then it will return the filename.
    var tipoArchivo= false;
    for(var i = 0; i <= allowed_extensions.length; i++)
    {
        if(allowed_extensions[i]==file_extension)
        {
     		tipoArchivo=true;
            return true; // valid file extension
            
        }
    }
    alertify.alert("Seleccione un archivo válido, de formato: .doc | .docx | .pdf | .xps | .jpg | .png | .gif");
	tipoArchivo=false;
    return false;
}
</script>